﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iS3.DAL.SQLSERVER
{
    public class SQLConn
    {
        public string server;
        public string database;
        public string uid;
        public string pwd;
        private string connectionSQL;
        public SQLConn()
        {

        }
        public SQLConn(string connectionSQL)
        {
            this.connectionSQL = connectionSQL;
            List<string> list = connectionSQL.Split(';').ToList();
            this.server = list[0].Trim().Split('=')[1];
            this.database = list[1].Trim().Split('=')[1];
            this.uid = list[2].Trim().Split('=')[1];
            this.pwd = list[3].Trim().Split('=')[1];
        }
        public string getMaster()
        {
            return string.Format("server={0}; database={1}; uid={2}; pwd={3};", server,"master", uid, pwd);
        }
        public string getConnectionStr()
        {
            return string.Format("server={0}; database={1}; uid={2}; pwd={3};", server, database, uid, pwd);
        }
    }

}
